using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebTools.UI.WebControls
{
	#region XmlDoc
	/// <summary>
	/// 
	/// </summary>
	/// <remarks>
	/// <para>
	/// 
	/// </para>
	/// </remarks>
	/// <example>
	/// 
	/// </example>
	#endregion
	[DefaultProperty("Text")]
	[System.Drawing.ToolboxBitmap("WebTools.UI.WebControls.ImageLiteral.bmp")]
	[ToolboxData("<{0}:ImageLiteral runat=server></{0}:ImageLiteral>")]
	[DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
	//[Designer("System.Web.UI.Design.WebControls.LiteralDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
	//[ControlBuilder(typeof(LiteralControlBuilder))]
	[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public class ImageLiteral : Literal
	{
		/// <summary>
		/// Sends server control content to a provided System.Web.UI.HtmlTextWriter object, 
		/// which writes the content to be rendered on the client.
		/// </summary>
		/// <param name="writer">A System.Web.UI.HtmlTextWriter that represents the output stream to render 
		/// HTML content on the client.</param>
		protected override void Render(HtmlTextWriter writer)
		{
			string url = this.ImageUrl;
			if (!String.IsNullOrEmpty(url))
			{
				Image img = new Image();
				img.ID = String.Format("{0}_Image", this.ID);
				img.ImageAlign = this.ImageAlign;
				img.ImageUrl = this.ResolveClientUrl(url);
				img.AlternateText = HttpUtility.HtmlEncode(this.Text);
				img.RenderControl(writer);
			}

			base.Render(writer);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <value></value>
		[Bindable(true)]
		[Category("Appearance")]
		[DefaultValue("")]
		[Localizable(true)]
		[Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
		public virtual string ImageUrl
		{
			get
			{
				object obj = ViewState["ImageUrl"];
				return ((obj == null) ? String.Empty : (string)obj);
			}

			set
			{
				ViewState["ImageUrl"] = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <value></value>
		[Bindable(true)]
		[Category("Appearance")]
		[DefaultValue("NotSet")]
		[Localizable(true)]
		public ImageAlign ImageAlign
		{
			get
			{
				object obj = ViewState["ImageAlign"];
				if (obj != null)
				{
				}
				return ImageAlign.NotSet;
			}
			set { ViewState["ImageAlign"] = value; }
		}
	}
}
